﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Management;

namespace XUtility
{
    /// <summary>
    /// 系统硬件类
    /// </summary>
    public class SystemClass
    {
        #region 获得CPU点
        /// <summary>
        /// 获得CPU点
        /// </summary>
        /// <returns></returns>
        public static String GetCPU()
        {
            String strCpu = null;
            ManagementClass myCpu = new ManagementClass("win32_Processor");
            ManagementObjectCollection myCpuConnection = myCpu.GetInstances();
            foreach (ManagementObject myObject in myCpuConnection)
            {
                strCpu = myObject.Properties["Processorid"].Value.ToString();
                break;
            }
            return strCpu;
        }
        #endregion

        #region 取得设备硬盘的卷标号
        /// <summary>
        /// 取得设备硬盘的卷标号 
        /// </summary>
        /// <returns></returns>
        public static String GetDiskVolumeSerialNumber()
        {
            ManagementClass mc = new ManagementClass("Win32_NetworkAdapterConfiguration");
            ManagementObject disk = new ManagementObject("win32_logicaldisk.deviceid=\"c:\"");
            disk.Get();
            return disk.GetPropertyValue("VolumeSerialNumber").ToString();

        }
        #endregion
    }
}
